qui(
    function (require, exports, module) {
        VODNew.EditMerge = function (options) {
            this.dao = VODNew.Dao;
            this.task = VODNew.Task;
            this.config = VODNew.Config;
            this.options = options || {};
        };
        Com.inherits(VODNew.EditMerge, Ancestor.Grid, function (options) {
        }).extend({
            init: function () {
                VODNew.Util.nonIntelligentData();
                VODNew.Util.checkGreyMode();
                VODCom.Player.initPlayer({
                    accurateFrame: VODNew.AccurateFrame,
                    dao: VODNew.Dao,
                    tips: VODNew.Plugin.tips
                });
                VODCom.NewsHighlight.bindConfig( VODNew)
                var self = this;
                self.initPointTime();
                $("#navDiv").tabs({active: 1});
                self.initDlg();
                self.bindEvent();
                self.initBodyEvent();
                self.initSuggest();
                self.initInterValTask();
                self.initGrid();
                self.initWordCount();

                self.config.DOT_SUBMIT_TIME = VODNew.Util.formatDateTimeFormat(new Date());
                $("#navMaskDiv").tabs();
                VODNew.Util.checkAdvertSupport();

            },
            initWordCount: function () {
                VODNew.Util.canOverWordCount($("input[name=videoName]"), 43, null, null, function (length) {
                    var infoHint = $("span[span-mode=info]");
                    var warnHint = $("span[span-mode=warn]");
                    if (length >= 0) {
                        infoHint.find("span.leftWordsCount").text(length / 2);
                        infoHint.show();
                        warnHint.hide();
                    } else {
                        infoHint.hide();
                        warnHint.show();
                        warnHint.find("span.overWordsCount").text(-length / 2);
                    }
                });

                VODNew.Util.canOverWordCount($("input[name=image_ocr_title]"), 43, null, null, function (length) {
                    var infoHint = $("span[span-mode=info2]");
                    var warnHint = $("span[span-mode=warn2]");
                    if (length >= 0) {
                        infoHint.find("span.leftWordsCount").text(length / 2);
                        infoHint.show();
                        warnHint.hide();
                    } else {
                        infoHint.hide();
                        warnHint.show();
                        warnHint.find("span.overWordsCount").text(-length / 2);
                    }
                });

                VODNew.Util.canOverWordCount($("input[name=image_auto_title]"), 43, null, null, function (length) {
                    var infoHint = $("span[span-mode=info3]");
                    var warnHint = $("span[span-mode=warn3]");
                    if (length >= 0) {
                        infoHint.find("span.leftWordsCount").text(length / 2);
                        infoHint.show();
                        warnHint.hide();
                    } else {
                        infoHint.hide();
                        warnHint.show();
                        warnHint.find("span.overWordsCount").text(-length / 2);
                    }
                });


                VODNew.Util.limitWordCount($("input[name=fantasyTitle]"), 80, null, null, function (length) {
                    $("span.leftWordsCount1").text(length / 2);
                });
            },

            foldDivMakeUp: function (element) {
                var global = VODNew.Config.Global;
                var style = global.smallPic ? "width:120px;height:96px" : "width:280px;height:220px";
                var htmlArr = [];
                htmlArr.push('<div class="text-center relative" style="' + style + '" fold-key="' + (element.start + "_" + element.end) + '" fold-start="' + element.start + '" fold-end="' + element.end + '">')
                htmlArr.push(' 收纳' + element.start + '~' + element.end);
                htmlArr.push('<br><span style="cursor: pointer" onclick="VODCom.Pic.extendPics(this)">展开</span>');
                htmlArr.push('</div>');
                $(htmlArr.join("")).insertBefore($("#img-" + element.start).parent());
            },

            initBodyEvent: function () {
                var self = this;
                var browser = VODNew.Util.getUserAgent();
                VODNew.Util.detectBrowserSupport(browser);
                VODNew.Util.LayoutInit();

                self.dao.storageData('ASS', 'off'); // 自动拆条开关
                self.dao.storageData('BCS', 'off'); // 背景颜色开关

                VODNew.Evt.InitBindEvt();

                VODNew.Util.browserZoomTips();
                $("body").show();
                $("body").on('click', '[action-name]', function () {
                    var self = $(this),
                        name = self.attr('action-name');
                    switch (name) {
                        case 'segmentation':
                            VODNew.Evt.ShowAndHideSegmentationList();
                            break;
                        case 'segmentation-assist':
                            VODNew.Evt.ShowAndHideSegmentationAssistList();
                            break;
                        case 'switch': // 拆条背景颜色打开与关闭
                            VODNew.Evt.OpenOrCloseBk(self);
                            break;
                        default:
                            break;
                    }
//                    case 'segmentation':
//                    case 'segmentation-assist':
//                    case 'segmentation-fragment':
//                    VODNew.Evt.ShowAndHideList(name);
//                    break;
                });
            },

            initInterValTask: function () {
                var self = this;
                VODNew.Config.HeartBeat = VODNew.Util.createHeartBeatUtil();
                //          setInterval(self.task.getData, 5000);   // 获取图片数据
                // 获取ocr标题数据
                //setInterval(getCate,20000);
                //     setInterval( self.task.doHeartBeat,1000) // 心跳
                VODNew.Config.HeartBeat.pushTask({needBlock: false, gap: {s: 5}, handler: function () {
                    self.task.getData();
                }});
                var fgOptions = {
                    needBlock: true,
                    stop: true,
                    //      gap: {s: 30},
                    gap: auth.dev() ? {m: 2} : {m: 30},
                    handler: function () {
                        console.log("blockHBId  " + VODNew.Config.fgRemindObj.id);
                        if (!VODNew.Util.isAppendFragmentMode()) {
                            VODNew.Config.fgRemindObj.stop = true;
                            return;
                        }
                        VODNew.Evt.doFragmentSubmitRemind();
                    }}
                VODNew.Config.fgRemindObj = VODNew.Config.HeartBeat.pushTask(fgOptions);
                VODNew.Config.Global.sty2Data.list = [];
                VODNew.Config.HeartBeat.start();
            },
            initPointTime: function () {
                //默认时间
                var today_d = new Date();
                if (today_d.getMinutes() > 2) {
                    today_d.setTime(today_d.getTime() - 120000);
                }
                var s_d = VODNew.Util.formatDateTimeFormat(today_d);
                today_d.setTime(today_d.getTime() + 4 * 3600 * 1000);
                var e_d = VODNew.Util.formatDateTimeFormat(today_d);

                $('#inputStartTime').val(s_d);
                $('#inputEndTime').val(e_d);
                if (s_d >= e_d) {
                    return
                }
                VODNew.Util.bindDate("inputStartTime", "inputEndTime", { maxDate: e_d, maxDateTime: new Date(e_d.replace(/-/g, "/")), minDate: s_d, minDateTime: new Date(s_d.replace(/-/g, "/")), slider: true});
                $("input[name=inputStartTime]").datetimepicker("setDate", new Date(s_d.replace(/-/g, "/")));
                $("input[name=inputEndTime]").datetimepicker("setDate", new Date(e_d.replace(/-/g, "/")));
            },
            initDlg: function () {
                var self = this;
                self.initAlterTitleDlg();
                self.initAlertDlg();
                self.initImageMarkDlg();
                self.initFragmentDlg();
                self.initImageMaskDlg();
                self.initHelp();
                VODCom.AutoTitle.initAutoTitleDlg({
                    settings: self.dao.settings,
                    dao: self.dao,
                    tips: VODNew.Plugin.tips,
                    validate: VODNew.Plugin.Validate,
                    config: self.config,
                    util: VODNew.Util,
                    body:$("body")
                });
                $(".ui-dialog-titlebar-close").html('<span class="ui-button-icon-primary ui-icon ui-icon-closethick"></span><span class="ui-button-text">close</span>');
                $('#alert-time').datetimepicker();
                $('button[data-dismiss=modal]').on('click', function () {
                    VODNew.AccurateFrame.accurateStartEndRemove()
                });
            },
            initHelp: function () {
                var self = this;
                $("#help-dlg").dialog({
                    title: "打点系统帮助",
                    resizable: false,
                    dialogClass: 'alert',
                    autoOpen: false,
                    width: 660,
                    modal: true
                })
                var innerText = "";
                $.each(VODNew.Config.HELP_DATA, function (i, data) {
                    innerText += '<tr><td>' + data[0] + '</td><td>' + data[1] + '</td></tr>'
                })
                $("#help-dlg").find("tbody").html(innerText);


                $("#help-pop").bind("click", function () {
                    var helpDlg = $("#help-dlg")
                    if (self.dao.storageData('coderVersion') == undefined) {
                        self.dao.getCodeVersion({});
                        if (self.dao.storageData('coderVersion') == undefined) {
                            self.dao.storageData('coderVersion', '0 | 0 | 0');
                        }
                        helpDlg.dialog("open");
                        helpDlg.find("label[name=coderVersion]").html("版本 V3.2.2 | " + self.dao.storageData('coderVersion'));
                    } else {
                        helpDlg.dialog("open");
                    }
                })
            },
            initAlterTitleDlg: function () {
                $("#alter_title-dlg").dialog({
                    title: "请选择该新闻标题",
                    resizable: false,
                    dialogClass: 'alert',
                    autoOpen: false,
                    width: 350,
                    modal: true
                })

                $("button[name=alter_title-ok]").bind("click", function (e) {
                    VODNew.Util.updateNewsGridRowData();
                    $("#alter_title-dlg").dialog("close");
                });
                $("button[name=alter_title-cancel]").bind("click", function (e) {
                    $("#alter_title-dlg").dialog("close");
                });
            },


            initAlertDlg: function () {
                $("#alert-dlg").dialog({
                    title: "定时提醒",
                    resizable: false,
                    dialogClass: 'alert',
                    autoOpen: false,
                    width: 600,
                    modal: true
                })
                $("#alert-pop").bind("click", function () {
                    $("#alert-dlg").dialog("open");
                })

                $("button[name=alert-dlg-cancel]").bind("click", function (e) {
                    $("#alert-dlg").dialog("close");
                });
                $("button[name=alert-dlg-ok]").bind("click", function (e) {
                    VODNew.Evt.RegularTimeRemind();
                    $("#alert-dlg").dialog("close");
                });
            },
            initImageMarkDlg: function () {
                $("#image_mark-dlg").dialog({
                    title: "图片标题识别",
                    resizable: false,
                    dialogClass: 'alert',
                    autoOpen: false,
                    width: 1120,
                    modal: true
                })

                $("button[name=image_mark-ok]").bind("click", function (e) {
                    VODNew.MarkOcrManager.fillByOcrTitle();
                    $("#image_mark-dlg").dialog("close");
                });
                $("button[name=image_mark-cancel]").bind("click", function (e) {
                    $("#image_mark-dlg").dialog("close");
                });
                VODNew.Config.CropInstance = $.Jcrop("#ocr_image", {
                    onChange: VODNew.MarkOcrManager.doCropChange,
                    onSelect: VODNew.MarkOcrManager.doCropSelect,
                    boxHeight: 603,
                    minSelect: [10, 10]
                })
            },
            initImageMaskDlg: function () {
                $("#image_mask-dlg").dialog({
                    title: "遮标",
                    resizable: false,
                    dialogClass: 'alert',
                    autoOpen: false,
                    width: 1120,
                    modal: true
                })
                VODNew.MaskManager.initManager({
                    gridTarget: $("#mask_list"),
                    dlgTarget: $("#image_mask-dlg"),
                    maskDivTarget: $("#maskDiv"),
                    imageTarget: $("#mask_image"),
                    btn_preview: $("button[name=image_mask-preview]"),
                    btn_ok: $("button[name=image_mask-ok]"),
                    btn_cancel: $("button[name=image_mask-cancel]")
                })
            },
            initFragmentDlg: function () {
                $("#fragment-dlg").dialog({
                    title: "快速直转点提交提示",
                    resizable: false,
                    dialogClass: 'no-close',
                    autoOpen: false,
                    width: 600,
                    modal: true,
                    closeOnEscape: false
                })

                $("button[name=fragment-ok]").on("click", function (event) {
                    $("#fragment-dlg").dialog("close");
                    VODNew.Util.autoFillFragmentEnd();
                    VODNew.Util.handlerRemoveFgRemindBlock();
                })
                $("button[name=fragment-cancel]").on("click", function (event) {
                    $("#fragment-dlg").dialog("close");
                    VODNew.Util.handlerRemoveFgRemindBlock();
                })
            },

            queryBeforeInit: function () {
                VODNew.Config.PageBeanFrame.setNewData([]);
                VODNew.Config.PageBeanAdvert.setNewData([]);
                VODNew.Config.PageBeanNewsSubmit.setNewData([]);
                VODNew.Config.PageBeanNewsDel.setNewData([]);
                VODNew.Config.lastSubmitObj = { programId: -1, hasSubmit: false}
                VODNew.Config.lastLegoSubmitObj = { programId: -1, hasSubmit: false}
                VODNew.Config.fragmentPid = 0;
                VODNew.Config.LAST_FRAGMENT_REMIND_TIME = 0;
                VODNew.Config.LAST_FRAGMENT_REMIND_ENABLE = false;
                VODNew.Config.AUTO_SUBMIT_TRIGGER = false;

                VODNew.Util.updateGridFrame();
                VODNew.Util.updateGridAdvert();
                VODNew.Util.updateGridNewsSubmit();
                VODNew.Util.updateGridNewsDel();
                VODNew.MaskManager.clearMaskEntity();
                VODNew.AccurateFrame.doReset();
                VODNew.AccurateFrame.adTipRemove();
                VODCom.NewsHighlight.setHighLight(null);
            },

            queryImage: function () {
                var self = this;
                var settings = self.dao.settings;
//                var sty = '';
                if (self.dao.storageData('ASS') == 'on') {
                    if (!self.dao.storageData('sty-intval')) {
                        //   sty = setInterval(self.dao.getSty, 10000);
                        self.dao.storageData('sty-intval', 1);
                    }
                } else {
                    //  clearInterval(sty);
                    self.dao.storageData('sty-intval', 0);
                    self.dao.storageData('sty-index', 0);
                    VODNew.g_mi = 0;
                    VODNew.g_i = 0;
                }

                // 清除已列拆条
                $('.inner-table').parents('tr').remove();
                $('.merg-seg-tips,.auto-seg-tips').show();

                self.updateDaoSetting();

                var start = VODNew.Util.validStart();
                if (!start) {
                    return false;
                }
                $('#makedImg').html('正在请求数据，请等待！');
                $('#makedImg').data("fold", []);
                var paramsData = self.dao.getParamsData();
                var dotData = self.dao.getDotData();
                VODNew.Util.clearOldTaskData();
                self.dao.getInitTaskId({
                    'start': start,
                    'period': settings.period,
                    'code': paramsData.channel_name,
                    'from_client': true
                }, function (data) {
                    if (data == null) {
                        VODNew.Plugin.tips("error", '网络错误');
                    } else {
                        if (data.taskid != null && data.taskid > 0) {
                            settings.taskid = parseInt("" + data.taskid);
                            settings.lastImg = 0;
                            //开始请求数据
                            settings.isStart = true;
                            $('#makedImg').empty();
                            self.task.getData();
                            self.queryNews();
                        } else {
                            //alert('系统错误:任务id为空');
                            VODNew.Plugin.tips("error", '系统错误:任务id为空');
                        }
                    }
                })
                //////////////////////////////////////////
                //////////////////////////////////////////
            },
            bindChangePicEvent: function () {
                var self = this;
                var settings = self.dao.settings;
                var global = VODNew.Config.Global;

                VODCom.Pic.eventManager.bindEvent("fold_makeUp", function (element) {
                    self.foldDivMakeUp(element)
                })

                $('#changeBigPic').bind("click", function (event) {
                    settings.lb = 1;
                    $('.right img').css({
                        'width': '264px',
                        'height': '204px'
                    });
                    VODNew.Config.Global.picWH = VODNew.Config.BIG_PIC_MODE;
                    $(this).addClass('btn-primary');
                    $('#changeSmallPic').removeClass('btn-primary');
                    $('.breakWord').remove();
                    if (global.isClicked) {
                        if ($('.red').length > 0) {
                            var sTop = $('#makedImg').scrollTop() + $('.red').offset().top;
                            $('#makedImg').scrollTop(sTop);
                        }
                    }
                    global.smallPic = false;
                    $('.fp_time').removeClass('fp_time').addClass('fp_time2');
                    $('.in-out-mark-s').addClass('in-out-mark-b');
                    settings.fpTime = 'fp_time2';
                    VODNew.Util.getLineWidth();
                    $("#play-one").css({
                        width: "274px",
                        height: "210px"
                    });
                    VODCom.Pic.eventManager.dispatchEvent({type: "change_big_pic", data: []});
                })
                $('#changeSmallPic').bind("click", function (event) {
                    settings.lb = 1;
                    $('.right img').css({
                        'width': '104px',
                        'height': '64px'
                    });
                    VODNew.Config.Global.picWH = VODNew.Config.SMALL_PIC_MODE;
                    $(this).addClass('btn-primary');
                    $('#changeBigPic').removeClass('btn-primary');
                    $('.breakWord').remove();
                    if (global.isClicked) {
                        if ($('.red').length > 0) {
                            var sTop = $('#makedImg').scrollTop() + $('.red').offset().top;
                            $('#makedImg').scrollTop(sTop);
                        }
                    }
                    global.smallPic = true;
                    $('.fp_time2').removeClass('fp_time2').addClass('fp_time');
                    $('.in-out-mark-s').removeClass('in-out-mark-b');
                    settings.fpTime = 'fp_time';
                    VODNew.Util.getLineWidth();
                    $("#play-one").css({
                        width: "140px",
                        height: "105px"
                    });
                    VODCom.Pic.eventManager.dispatchEvent({type: "change_small_pic", data: []});
                })
            },

            bindEvent: function () {
                var self = this;
                VODNew.Evt.InitBindEvt();
                $('#submitStartTime').click(function () {
                    self.queryBeforeInit();
                    self.queryImage();
                })


                self.bindChangePicEvent();
                $("button[name=cancel-import]").bind("click", function (event) {
                    VODNew.Util.doClearImportData();
                })

                self.bindReviewInfo();
                self.bindAddInfo();
                self.bindJumpSubmitHandler();
                self.bindMarkImgHandler()

                $('select[name=jumpType]').change(function () {
                    if ($(this).val() == 1) {
                        $('#jumpContent').val('00:00:00');
                    } else {
                        $('#jumpContent').val('0');
                    }
                })
                $('#autoRunPic').click(function () {
                    if ($(this).prop('checked')) {

                        $('#makedImg').scrollTop($('#makedImg')[0].scrollHeight);
                    }
                })

                $("input[name=videotype]").bind('click', function () {
                    $('input[name=albumName],input[name=categoryName]').removeAttr('disabled');
                    //settings.videonameArr = [];
                    $('input[name=videoName]').suggest("setValue", "");
                    $("input[name=albumName]").suggest("setValue", "");
                    if ($(this).val() == -1) {
                        $('#fantasyTitleDiv').css('display', 'block');
                        if ($("input[name=categoryName]").suggest("getValue") == "25" && $("input[name=categoryName]").val() == "资讯") {
                            $("#locationDiv").show();
                        } else {
                            $("#locationDiv").hide();
                        }
                    } else {
                        $("#locationDiv").hide();
                        $('#fantasyTitleDiv').css('display', 'none');
                    }
                    if ($(this).val() == 0 || $(this).val() == 1) {
                        $('input[name=albumName],input[name=categoryName]').attr("disabled", true);
                    }
                    var categoryName = $("input[name=categoryName]").val();
                    VODNew.Util.setCooperativePartner(categoryName);
                });

                $("input[name=isAppendFragment]").bind("click", function () {
                    if ($(this).val() == 1) {
                        if (VODNew.Util.checkChangeFragmentMode()) {
                            VODNew.Util.transToFragmentMode();
                        } else {
                            return false;
                        }
                    } else if ($(this).val() == 0) {
                        VODNew.Util.transToNormalMode();
                    }
                })

                $('input[name=eTime]').blur(function () {
                    VODNew.Util.fillDefaultTitle();
                })
                $("#div_fragment_append").delegate("button[name=btn_submit_fragment]", "click", function (event) {
                    var _self = this;
                    var parentDiv = $(_self).parent()
                    var eTimeVal = parentDiv.find("input:eq(1)").val();
                    var sTimeVal = parentDiv.find("input:eq(0)").val();
                    if (eTimeVal.length == 0 || isNaN(eTimeVal)) {
                        return;
                    }
                    if (parseInt(sTimeVal) >= parseInt(eTimeVal)) {
                        VODNew.Plugin.tips("error", "分片起始帧需小于分片结束帧");
                        return;
                    }
                    var finalETime = $("input[name=eTime]").val();
                    if (finalETime.length > 0 && !isNaN(finalETime) && parseInt(eTimeVal) > parseInt(finalETime)) {
                        VODNew.Plugin.tips("error", "分片结束帧大于成片结束帧");
                        return;
                    }
                    var handler = function () {
                        $(_self).hide();
                        VODNew.Util.handlerRemoveFgRemindBlock();
                        VODNew.Util.doFragmentSubmit(parentDiv, {
                            doSuc: function () {
                                VODNew.Util.addToDivFragment();
                            },
                            doError: function (msg, logOnly) {
                                console.error(msg);
                                if (logOnly == null || !logOnly) {
                                    VODNew.Plugin.tips("error", msg);
                                }
                                $(_self).show();
                            },
                            doRevert: function () {
                                $('input[name=isAppendFragment]').removeAttr("disabled");
                                $('input[name=isAppendFragment][value="0"]').click();
                            }
                        })
                    }

                    if (VODNew.Config.AUTO_SUBMIT_TRIGGER == true) {
                        VODNew.Config.AUTO_SUBMIT_TRIGGER = false;
                        handler();
                    } else {
                        SystemDialog.queryConfirm(VODNew.Config.REMIND_MSG_INFO.FRAGMENT_SUBMIT, function (flag) {
                            if (flag == true) {
                                handler();
                            }
                        }, {"btn_ok": "确认提交分片", "btn_cancel": "去提交广告" })
                    }
                })

                $("#div_fragment_append").delegate("button[name=btn_preview_fragment]", "click", function (event) {
                    var parentDiv = $(this).parent()
                    var eTimeVal = parentDiv.find("input:eq(1)").val();
                    if (eTimeVal.length == 0 || isNaN(eTimeVal)) {
                        return;
                    }
                    var sTimeVal = parentDiv.find("input:eq(0)").val();
                    if (parseInt(sTimeVal) > parseInt(eTimeVal)) {
                        VODNew.Plugin.tips("error", "分片起始帧不能大于分片结束帧");
                        return;
                    }
                    console.log(" btn_preview_fragment click ");
                    VODNew.Util.doReview(parentDiv.find("input:eq(0)").val(), eTimeVal, true);
                })

                $("#div_fragment_append").delegate("div>input", "keyup afterpaste", function (event) {
                    this.value = this.value.replace(/\D/g, '')
                })
                VODCom.AutoTitle.bindEvent();
            },
            updateDaoSetting: function () {
                var self = this;
                var settings = {
                    index: 1,
                    newsSubmitIndex: 1,
                    newsDelIndex: 1,
                    stime: 0,
                    etime: 0,
                    pic: 0,
                    taskid: 0,
                    lastImg: 0,
                    delList: [],
                    subData: [],
                    needDatas: [],
                    isStart: false,
                    isSetFpTime: false,
                    lb: 1,
                    firstFpTime: 0,
                    last_i: 0,   // 上次识的库索引
                    adLibList: [],
                    isOver: 1  //防止并发
                }
                if (!$('#changeBigPic').hasClass('btn-primary')) {
                    settings.fpTime = 'fp_time';
                } else {
                    settings.fpTime = 'fp_time2';
                }
                VODNew.Util.updateObjectData(settings, self.dao.settings);
            },
            bindAddInfo: function () {
                $("#d_addInfo").on("click", function () {
                    VODNew.Advert.del_submit()
                })
                $('#addInfo').click(function () {
                    VODNew.Util.dot_submit()
                    $('#addInfo').removeAttr('disabled').html('提交');
                });
            },
            bindReviewInfo: function () {
                var self = this;
                $('#reviewInfo').bind("click", function (e) {
                    var sTime = $('input[name=sTime]').val(),
                        eTime = $('input[name=eTime]').val();
                    VODNew.Util.doReview(sTime, eTime, true)
                })
                $('#d_reviewInfo').bind("click", function (e) {
                    var sTime = $('input[name=d_sTime]').val(),
                        eTime = $('input[name=d_eTime]').val();
                    VODNew.Util.doReview(sTime, eTime, false)
                })

            },

            bindMarkImgHandler: function () {
                var self = this;
                var settings = self.dao.settings;
                $('#makedImg').on('click', 'img.fragment-img', function () {
                    VODNew.Config.Global.isClicked = true;  // 大小图片切换滚动到当前图片用
                    if ($(this).parent().find(".layout").hasClass("red")){
                        if (VODCom.H5Player.getPlayerData("flash").video.paused) {
                            VODCom.Player.doViewImage(true);
                        }
                        return;
                    }
                    $('.layout').removeClass('red');
                    if ($(this).parent().find(".layout").length !== 0)
                        $(this).parent().find(".layout").addClass("red");
                    else
                        $(this).parent().append(VODNew.Config.RED_LAYOUT);
                    settings.pic = settings.etime = settings.stime = $(this).parent().find('.pid').text().replace(/\s+/g, "");
                    VODCom.Player.viewStopImage(settings.pic)
                })
            },
            bindJumpSubmitHandler: function () {
                $('#jumpSubmit').click(function () {
                    var jumpType = $('select[name=jumpType]').val();
                    var jc = $('#jumpContent').val();
                    if (!VODNew.Util.isJumpData(jc, jumpType)) {
                        VODNew.Plugin.tips("error", '跳转输入格式错误');
                        return false;
                    }
                    var jumpContent = null;
                    if (jumpType == 1) {
                        jumpContent = jc.replace(/:/g, "-");
                        if (!$('.relative').hasClass(jumpContent)) {
                            var temStr = jumpContent.substr(jumpContent.length - 2);
                            if (temStr.length == 2 && temStr.substr(0, 1) == '0') {
                                temStr = temStr.charAt(temStr.length - 1);
                            }
                            var lasStr = parseInt(temStr);
                            if (lasStr == 0) {
                                lasStr += 10;
                            }
                            var beforeStr = jumpContent.substr(0, jumpContent.length - 2)
                            var untilStr = lasStr - 10;
                            if (untilStr < 0)
                                untilStr = 0;
                            var us
                            for (var i = lasStr; i >= untilStr; i--) {
                                if (i < 10) {
                                    us = 0 + String(i);
                                } else {
                                    us = String(i);
                                }
                                us = beforeStr + us;

                                if ($('.relative').hasClass(us)) {
                                    jumpContent = us;
                                    break;
                                }
                            }
                        }
                    } else {
                        jumpContent = jc + '-jump';
                    }
                    if ($('.relative').hasClass(jumpContent)) {
                        $('#makedImg').scrollTop(0)
                        sTop = $('.' + jumpContent).offset().top - 100;
                        $('#makedImg').scrollTop(sTop);
                    } else {
                        //alert('没有这帧');
                        VODNew.Plugin.tips("error", '没有这帧');
                    }
                })
            },
            initSuggest: function () {
                var self = this;


                var channelTypeSuggest = {
                    options: {
                        source: VODNew.urlConfig.redirect,
                        renderPanel: function (handler) {
                            self.dao.getChannelType(handler)
                        },
                        select: function (event, object) {
                            console.log("trihger  channelTypeSuggest");
                            $("input[name=albumName]").removeAttr("disabled");
                            $("input[name=albumName]").suggest("setValue", "");
                            if (object.item.id == 25 && $('input[name=videotype]:checked').val() == -1) {
                                $("#locationDiv").css('display', 'inline-block');
                            } else {
                                $("#locationDiv").css('display', 'none');
                            }
                            VODNew.Util.setCooperativePartner(object.item.value);
                            $("input[name=categoryName]").attr("bind-sel-name", object.item.value);
                            $("input[name=categoryName]").attr("bind-sel-id", object.item.id);
                            return true;
                        },
                        autoFilter: false,
                        method: "post",
                        multiple: false,
                        parseValue: function () {
                            var val = this.element.val(),
                                ret = []
                            return ret;
                        },
                        getParam: function (term) {
                            var params = term.length == 0 ? {size: 100} : {word: term, size: 100}
                            var requestData = {url: VODNew.Constant.thirdUrl_channel, type: "get", params: params, needCookie: true};
                            return {"request": JSON.stringify(requestData), timeSign: new Date().getTime()}
                        },

                        process: function (json) {
                            var ret = [],
                                self = this,
                                options = self.options,
                                itemData = null;
                            var data = null;
                            if (json == null) {
                                return [];
                            }
                            if (json.code === "A00000") {
                                data = $.isArray(json) ? json : json.data;
                            }
                            if (!data) {
                                return [];
                            }
                            $.map(data, function (item) {
                                itemData = {};
                                itemData[options.valueKey] = item["id"];
                                itemData[options.labelKey] = item["name"];
                                itemData["value"] = item["name"];
                                ret.push(itemData);
                            });
                            return ret;
                        },

                        template: function (item) {
                            return item["label"];
                        }
                    }
                }
                var albumSuggest = {
                    options: {
                        source: VODNew.urlConfig.redirect,
                        method: "post",
                        multiple: false,
                        parseValue: function () {
                            return [];
                        },
                        getParam: function (term) {
                            var channelId = $("input[name=categoryName]").suggest("getValue")
                            var requestData = {url: VODNew.Constant.thirdUrl_album, type: "get", params: {word: term, type: "displayName", filter_EQL_channel: channelId}, needCookie: true};
                            return {"request": JSON.stringify(requestData), timeSign: new Date().getTime()}
                        },
                        process: function (json) {
                            var ret = [],
                                self = this,
                                options = self.options,
                                itemData = null;
                            var data = null;
                            if (json == null) {
                                return [];
                            }
                            if (json.code === "A00000") {
                                data = $.isArray(json) ? json : json.data;
                            }
                            if (!data) {
                                return [];
                            }
                            $.map(data, function (item) {
                                itemData = {};
                                itemData[options.valueKey] = item["entityId"];
                                itemData[options.labelKey] = item["displayName"];
                                itemData["value"] = item["displayName"];
                                ret.push(itemData);
                            });
                            return ret;
                        },
                        template: function (item) {
                            return item["label"];
                        }
                    }
                }
                var locationSuggest = {
                    options: {
                        source: VODNew.urlConfig.redirect,
                        method: "post",
                        multiple: false,
                        parseValue: function () {
                            return [];
                        },
                        getParam: function (term) {
                            var requestData = {url: VODNew.Constant.thirdUrl_locationUrl, type: "get", params: {word: term, type: "province,city", domestic: 1}, needCookie: true};
                            return {"request": JSON.stringify(requestData), timeSign: new Date().getTime()}
                        },
                        process: function (json) {
                            var ret = [],
                                self = this,
                                options = self.options,
                                itemData = null;
                            var data = null;
                            if (json == null) {
                                return [];
                            }
                            if (json.code === "A00000") {
                                data = $.isArray(json) ? json : json.data;
                            }
                            if (!data) {
                                return [];
                            }
                            $.map(data, function (item) {
                                itemData = {};
                                itemData[options.valueKey] = item["id"];
                                itemData[options.labelKey] = item["name"];
                                itemData["value"] = item["name"];
                                ret.push(itemData);
                            });
                            return ret;
                        },
                        template: function (item) {
                            return item["label"];
                        }
                    }
                }

                var videoSuggest = {
                    options: {
                        source: VODNew.urlConfig.redirect,
                        method: "post",
                        multiple: false,
                        parseValue: function () {
                            return [];
                        },
                        validate: false,
                        getParam: function (term) {
                            var videotype = $('input[name=videotype]:checked').val();
                            $("input[name=videoName]").suggest("option", "stopSuggest", videotype == -1);
                            var requestData = {url: VODNew.Constant.thirdUrl_simple_video, type: "get", params: {word: term, type: "properTitle", isMade: videotype, filter_GTI_channel: 0 }, needCookie: true};
                            return {"request": JSON.stringify(requestData), timeSign: new Date().getTime()}
                        },
                        process: function (json) {
                            var ret = [],
                                self = this,
                                options = self.options,
                                itemData = null;
                            var data = null;
                            if (json == null) {
                                return [];
                            }
                            if (json.code === "A00000") {
                                data = $.isArray(json) ? json : json.data;
                            }
                            if (!data) {
                                return [];
                            }
                            $.map(data, function (item) {
                                itemData = {};
                                itemData[options.valueKey] = item["entityId"];
                                itemData[options.labelKey] = item["properTitle"];
                                itemData["value"] = item["properTitle"];

                                itemData["videoId"] = item["entityId"] || 0;
                                itemData["videoName"] = item["properTitle"] || "";

                                itemData["categoryName"] = item["categoryName"] || "";
                                itemData["categoryId"] = item["categoryId"] || 0;

                                itemData["albumName"] = item["albumDisplayName"] || "";
                                itemData["albumId"] = item["albumId"] || 0;
                                ret.push(itemData);
                            });
                            return ret;
                        },
                        select: function (event, object) {
                            if (object.item.albumId > 0) {
                                $("input[name=albumName]").suggest("setValue", {id: object.item.albumId, label: object.item.albumName})
                            } else {
                                $("input[name=albumName]").suggest("setValue", "")
                            }
                            if (object.item.videoId > 0) {
                                $("input[name=videoName]").suggest("setValue", {id: object.item.videoId, label: object.item.videoName});
                                $("input[name=videoName]").attr("bind-sel-name", object.item.videoName);
                                $("input[name=videoName]").attr("bind-sel-id", object.item.videoId);
                            } else {
                                $("input[name=videoName]").suggest("setValue", "")
                            }
                            if (object.item.categoryId > 0) {
                                $("input[name=categoryName]").suggest("setValue", {id: object.item.categoryId, label: object.item.categoryName});
                                $("input[name=categoryName]").attr("bind-sel-name", object.item.categoryName);
                                $("input[name=categoryName]").attr("bind-sel-id", object.item.categoryId);
                            } else {
                                $("input[name=categoryName]").suggest("setValue", "")
                            }
                            $('input[name=albumName],input[name=categoryName]').attr('disabled', 'disabled');
                            return true;
                        },
                        template: function (item) {
                            return item["label"];
                        }
                    }
                }

                $("input[name=categoryName]").suggest(channelTypeSuggest.options);
                $("input[name=categoryName]").bind("blur", function (event) {
                    console.log("categoryName  blur ");
                    setTimeout(function () {
                        if ($("input[name=categoryName]").val() == "资讯" && $("input[name=categoryName]").suggest("getValue") == "25") {
                            $("#locationDiv").show();
                        } else {
                            $("#locationDiv").hide();
                        }
                    }, 100)
                })
                $("input[name=albumName]").suggest(albumSuggest.options);
                $("input[name=location]").suggest(locationSuggest.options);
                $("input[name=videoName]").suggest(videoSuggest.options);
                var paramsData = self.dao.getParamsData();
                if (parseInt(paramsData.locationCategory) > 0) {
                    $("input[name=location]").suggest("setValue", {id: paramsData.locationCategory, label: decodeURI(paramsData.location)})
                }
            },
            initGrid: function () {
                var self = this;
                self.initFrameGrid();
                self.initAdvertGrid();
                self.initNewsGrid();
                self.initNewsSubmitGrid();
                self.initNewsDelGrid();
                self.initMaskGrid();
                self.queryNews();
            },
            initFrameGrid: function (options, callback) {
                var self = this;
                self.config.PageBeanFrame = VODNew.Util.createPageBean();
                var gridConfig = self.getGridConfig(self.config.TABLE_FRAME_LIST);
                options = $.extend(true, {}, gridConfig, options);
                self.options.$FrameGrid.jqGrid(options);
            },
            initAdvertGrid: function (options, callback) {
                var self = this;
                self.config.PageBeanAdvert = VODNew.Util.createPageBean();
                var gridConfig = self.getGridConfig(self.config.TABLE_ADVERT_LIST);
                options = $.extend(true, {}, gridConfig, options);
                self.options.$AdvertGrid.jqGrid(options);
            },
            initNewsSubmitGrid: function (options, callback) {
                var self = this;
                self.config.PageBeanNewsSubmit = VODNew.Util.createPageBean();
                var gridConfig = self.getGridConfig(self.config.TABLE_MERGE_SUBMIT_LIST);
                options = $.extend(true, {}, gridConfig, options);
                self.options.$NewsSubmitGrid.jqGrid(options);
            },
            initNewsDelGrid: function (options, callback) {
                var self = this;
                self.config.PageBeanNewsDel = VODNew.Util.createPageBean();
                var gridConfig = self.getGridConfig(self.config.TABLE_MERGE_DEL_LIST);
                options = $.extend(true, {}, gridConfig, options);
                self.options.$NewsDelGrid.jqGrid(options);
            },
            initMaskGrid: function (options, callback) {
                var self = this;
                self.config.PageBeanMaskEntity = VODNew.Util.createPageBean();
                var gridConfig = self.getGridConfig(self.config.TABLE_MASK_LIST);
                options = $.extend(true, {}, gridConfig, options);
                self.options.$MaskGrid.jqGrid(options);
                var htmlArr = [];
                htmlArr.push("<button type='button' onclick='VODNew.MaskManager.addMaskEntity()'>添加</button>");
                htmlArr.push("<button type='button' onclick='VODNew.MaskManager.clearMaskEntity()'>清空</button>");
                $("#mask_pager_left").css({width: "10px"});
                $(htmlArr.join("")).appendTo($("#t_mask_list"));
            },

            initNewsGrid: function (options, callback) {
                var self = this;
                self.config.PageBeanNews = VODNew.Util.createPageBean();
                var gridConfig = self.getGridConfig(self.config.TABLE_NEWS_LIST2);
                options = $.extend(true, {}, gridConfig, options);
                self.options.$NewsGrid.jqGrid(options);
                $("#news_list").setGridHeight(100)
                $("#news_pager_left").css({width: "10px"});
                var htmlArr = [];
                htmlArr.push("<button type='button' name='refresh_tab2'>刷新</button>");
//                htmlArr.push("<button type='button' onclick='VODNew.Util.doQuickAdd()'>添加</button>");
                htmlArr.push("<button type='button' onclick='VODNew.Util.doQuickMerge()'>合并</button>");
                htmlArr.push("<button type='button' onclick='VODNew.Util.doSelectedAll(true)'>全选</button>");
                htmlArr.push("<button type='button' onclick='VODNew.Util.doSelectedAll(false)'>清除选中</button>");
                $(htmlArr.join("")).appendTo($("#t_news_list"));
                $("button[name=refresh_tab2]").click(function (event) {
                    if (VODNew.Util.hasImportData()) {
                        VODNew.Util.doClearImportData("all")
                    }
                    self.queryNews();
                })
            },

            queryNews: function () {
                var self = this;
                var taskid = VODNew.Dao.settings.taskid;
                if (taskid == 0) {
                    console.log("queryNews taskid = 0");
                    return;
                }
                $("#news_list").jqGrid("setGridParam", {selrow: null});
                VODNew.Util.clearHighLight();
                self.dao.getNewsList({key: taskid, from_client: true, index: 0, type: 1, offset: 100 }, function (data) {
                    if (data != null && data.list != null) {
                        var formatArr = [];
                        self.dao.settings.reg_last_id = 0;
                        var regId = self.dao.settings.reg_last_id;
                        $.each(data.list, function (i, element) {
                            regId++;
                            formatArr.push({ title: element.text, sTime: element.video_list[0], eTime: element.video_list[element.video_list.length - 1], pic: element.cover, id: element.id, regId: regId, checked: false })
                        })
                        self.dao.settings.reg_last_id = regId
                        var lastSortSource = self.config.PageBeanNewsDel.getSource();
                        if (lastSortSource.length > 0) {
                            formatArr = VODNew.Util.doSourceRemove(lastSortSource, formatArr);
                        }
                        self.config.PageBeanNews.setNewData(formatArr, 100);
                    } else {
                        self.config.PageBeanNews.setNewData([], 100);
                    }
                    if (self.config.PageBeanNews.getSource().length > 0) {
                        VODNew.Util.hasIntelligentData();
                    } else {
                        VODNew.Util.nonIntelligentData();
                    }
                    var retValue = self.config.PageBeanNews.getCur();
                    self.options.$NewsGrid.clearGridData();
                    self.options.$NewsGrid[0].addJSONData(retValue);
                });
            }
        })
    }
);